package mlz.a_threadapi;

/*
    线程常用API
 */
public class Demo01 {
    public static void main(String[] args) {
        Thread t1 = new Thread() {
            @Override
            public void run() {
                for (int i = 0; i < 10; i++) {
                    Thread t = Thread.currentThread();
                    System.out.println(t.getName() + ":" + i);
                }
            }
        };

        Thread t2 = new Thread() {
            @Override
            public void run() {
                for (int i = 0; i < 10; i++) {
                    Thread t = Thread.currentThread();
                    System.out.println(t.getName() + ":" + i);
                }
            }
        };

        //设置 t1 和 t2 的名字
        t1.setName("高铁");
        t2.setName("飞机");

        //启动线程
        t1.start();
        t2.start();
    }
}
